<template>
	<view class="page">
		<view class="radio-item" v-for="index in 30" :key="index">
			<view class="left-box">
				<image class="radio" src="/static/image/radio_icon.png" mode="aspectFit"></image>
				<view class="info-box">
					<image class="user-icon" src="/static/image/user.png" mode=""></image>
					<view class="cityname">
						兰州市
					</view>
				</view>
			</view>
			<view class="right-box">
				<image class="right-icon" src="/static/image/more_right_icon.png" mode="aspectFit"></image>
			</view>
		</view>
		<view class="clearbottom"></view>
		<view class="button-box">
			<view class="button">
				确认
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			/**
			 * 选中当前地区触发事件
			 */
			selected:function(index,item){
				let addressInfo = this.addressInfo;
				let areaType = this.areaType;
				let selected = getApp().globalData.selected;
				if(selected == null){
					selected = {};
				}
				if(areaType == 'province'){
					addressInfo.province = index;
					selected.province = {index:index,value:item};
				}else if(areaType == 'city'){
					addressInfo.city = index;
					selected.city = {index:index,value:item};
				}else if(areaType == 'region'){
					addressInfo.region = index;
					selected.region = {index:index,value:item};
				}
				console.log('selected',selected);
				getApp().globalData.selected = selected;
			},
			confirm:function(){
				let areaType = this.areaType;
				let addressInfo = this.addressInfo;
				if(addressInfo.province == null){
					uni.showToast({
						title: '请选择省份',
						icon:'none',
						duration: 2000
					});
					return;
				}
				getApp().globalData.address = getApp().globalData.selected;
				if(areaType == 'province'){
				uni.navigateBack();
				}else if(areaType == 'city'){
					uni.navigateBack({
						delta: 2
					});
				}else if(areaType == 'region'){
					uni.navigateBack({
						delta: 3
					});
				}
			},
			/**
			 * 跳转内页选择更多地区触发事件
			 */
			jump:function(index,item){
				this.selected(index,item);
				let areaType = this.areaType;
				let type = '';
				if(areaType == 'province'){
					type = 'city';
				}else if(areaType == 'city'){
					type = 'region';
				}
				uni.navigateTo({
					url: '/subcontractList/order/address/area/area?areatype='+type
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page{
		background-color: #fafafa;
		width: 100%;
		min-height: 100vh;
	}
	.radio-item{
		display: flex;
		background-color: white;
		margin: 0 20rpx;
		height: 100rpx;
		padding:0 20rpx;
		border-bottom: 1px solid #fafafa;
		justify-content: space-between;
		.left-box{
			display: flex;
			.radio{
				margin:25rpx 0;
				width: 50rpx;
				height: 50rpx;
			}
			.info-box{
				display: flex;
				.user-icon{
					display: block;
					margin:20rpx;
					width:60rpx;
					height:60rpx;
					background-color: #cccccc;
					border-radius: 100%;
				}
				.cityname{
					line-height:100rpx;
					font-size: 28rpx;
				}
			}
		}
		.right-box{
			.right-icon{
				margin: 30rpx 0;
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
	.button-box{
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;
		background-color: #fafafa;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
		.button{
			width: 100%;
			line-height: 80rpx;
			text-align: center;
			font-size: 28rpx;
			border-radius: 10rpx;
			color: white;
			background-color: #4169e1;
		}
	}
</style>
